package cn.ch.train.business.controller.admin;

import cn.ch.train.common.context.LoginMemberContext;
import cn.ch.train.common.response.CommonResponse;
import cn.ch.train.common.response.PageResult;
import cn.ch.train.business.request.TrainSeatQueryParam;
import cn.ch.train.business.request.TrainSeatSaveParam;
import cn.ch.train.business.response.TrainSeatQueryResult;
import cn.ch.train.business.service.TrainSeatService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/train-seat")
public class TrainSeatAdminController {
    @Autowired
    private TrainSeatService trainSeatService;

    @PostMapping("/save")
    public CommonResponse save(@Valid @RequestBody TrainSeatSaveParam param) {
        trainSeatService.save(param);
        return new CommonResponse<>();
    }

    @GetMapping("/query-list")
    public CommonResponse<PageResult<TrainSeatQueryResult>> queryList(@Valid TrainSeatQueryParam param) {
        PageResult<TrainSeatQueryResult> trainSeatList = trainSeatService.queryList(param);
        return new CommonResponse<>(trainSeatList);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResponse delete(@PathVariable Long id) {
        trainSeatService.delete(id);
        return new CommonResponse<>();
    }

}
